Avoid silently losing mail via fakemail.
authorRob Browning <rlb@defaultvalue.org>
Tue, 5 Apr 2011 03:46:27 +0000 (22:46 -0500)
committerRob Browning <rlb@defaultvalue.org>
Thu, 7 Apr 2011 05:49:44 +0000 (00:49 -0500)
An attempt is made to avoid silently losing mail via fakemail.

This fix attempts to avoid a situation where Emacs can silently lose
mail.  This can occur if sendmail.el (at least) falls back to
fakemail, and the underlying binary (MAIL_PROGRAM_NAME) that fakemail
is configured to use doesn't exist.  Unless mail-interactive is true,
Emacs won't wait for the mailer and so won't know that fakemail
failed.

For now, Debian sets fakemail's MAIL_PROGRAM_NAME to /usr/bin/mail
(which is the correct value for Debian systems) rather than /bin/mail.
Debian also adjusts Emacs to test whether or not /usr/bin/mail exists
and is executable.  If either of these tests fail, then
mail-interactive is set to t.  That should ensure that a user will
actually see an error if they attempt to use the broken fakemail.

Note that Debian actually forces the MAIL_PROGRAM_NAME value to
/usr/bin/mail.  The build will fail if any other value is specified.
This is done to ensure that MAIL_PROGRAM_NAME isn't accidentally set
to some other value during the build process.  If this is undesirable
for some reason, just comment out avoid-fakemail-loss.diff in
debian/patches/series.

Author: Rob Browning <rlb@defaultvalue.org>
Added-by: Rob Browning <rlb@defaultvalue.org>
lib-src/fakemail.c
lisp/gnus/message.el
lisp/mail/feedmail.el
lisp/mail/sendmail.el

index f83c0fb5b4104d2f869b7ea45e818dfc2db53f0e..5c5fb6da74ed20c92fd436a90b4180546febc26d 100644 (file)
@@ -136,8 +136,10 @@ struct linebuffer lb;
 #define NIL ((line_list) NULL)
 #define INITIAL_LINE_SIZE 200
 
-#ifndef MAIL_PROGRAM_NAME
-#define MAIL_PROGRAM_NAME "/bin/mail"
+#ifdef MAIL_PROGRAM_NAME
+#error "Debian assumption violated -- see avoid-fakemail-mail-loss.diff"
+#else
+#define MAIL_PROGRAM_NAME "/usr/bin/mail"
 #endif
 
 static char *my_name;
index 63fcf500189e4ae1e533872096a2c777a0571f99..d6a417aa55749cc18ab86808cfc1dc2cd8dfba0f 100644 (file)
@@ -4609,7 +4609,13 @@ If you always want Gnus to send messages in one piece, set
                                     "/usr/lib/sendmail")
                                    ((file-exists-p "/usr/ucblib/sendmail")
                                     "/usr/ucblib/sendmail")
-                                   (t "fakemail"))
+                                   (t
+                                     (if (not (file-executable-p
+                                               "/usr/bin/mail"))
+                                         (progn
+                                           (message "/usr/bin/mail is not an executable.  Setting mail-interactive to t.")
+                                           (setq mail-interactive t)))
+                                     "fakemail"))
                              nil errbuf nil "-oi")
                        message-sendmail-extra-arguments
                        ;; Always specify who from,
index 77d82f6076f369b12dde751d01888d9812508eac..29cc8919a6d6d73bc323930bc4baff72af658217 100644 (file)
@@ -1327,7 +1327,12 @@ complicated cases."
                              "/usr/lib/sendmail")
                             ((file-exists-p "/usr/ucblib/sendmail")
                              "/usr/ucblib/sendmail")
-                            (t "fakemail"))
+                            (t
+                              (if (not (file-executable-p "/usr/bin/mail"))
+                                  (progn
+                                    (message "/usr/bin/mail is not an executable.  Setting mail-interactive to t.")
+                                    (setq mail-interactive t)))
+                              "fakemail"))
                       nil errors-to nil "-oi" "-t")
                 ;; provide envelope "from" to sendmail; results will vary
                 (list "-f" user-mail-address)
index 8cd650317b19addf50921cc239657bd50876219f..1adc2caf5d4b77d9b3c6ad9a4d423955509eb5b7 100644 (file)
     ((file-exists-p "/usr/sbin/sendmail") "/usr/sbin/sendmail")
     ((file-exists-p "/usr/lib/sendmail") "/usr/lib/sendmail")
     ((file-exists-p "/usr/ucblib/sendmail") "/usr/ucblib/sendmail")
-    (t "fakemail"))                    ;In ../etc, to interface to /bin/mail.
+    (t
+     (if (not (file-executable-p "/usr/bin/mail"))
+         (progn
+           (message "/usr/bin/mail is not an executable.  Setting mail-interactive to t.")
+           (setq mail-interactive t)))
+     "fakemail"))                      ;In ../etc, to interface to /bin/mail.
   "Program used to send messages."
   :group 'mail
   :type 'file)